package com.house365.app.analyse.dao;

import java.net.MalformedURLException;
import java.net.URL;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.house365.sdk.sqlite.SQLiteAssetHelper;

@SuppressLint("NewApi")
public class AnalyticsDB {
    private static final String DB_NAME = "analytics.db";
    public static final int VERSION = 1;
    private SQLiteAssetHelper mSQLiteHelper;
    protected SQLiteDatabase db;
    
    public AnalyticsDB(Context context) {
        String path = context.getFilesDir().getAbsolutePath();
        String sss = AnalyticsDB.class.getResource("analytics_create_1.sql").toString();
        String substring = sss.substring(0, sss.lastIndexOf("/"));
        URL url = null;
        try {
            url = new URL(substring);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        mSQLiteHelper = new SQLiteAssetHelper(context, url, DB_NAME, path, null, VERSION);
        db = mSQLiteHelper.getWritableDatabase();
    }

}
